
import 'package:find_friend/const/const.dart';
import 'package:find_friend/pages/mine/mine_home.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'mine_dressup/mine_dressup.dart';

class MineScreen extends StatefulWidget {

  @override
  _MineScreenState createState() => _MineScreenState();
}

class _MineScreenState extends State<MineScreen> with AutomaticKeepAliveClientMixin {

  bool isbottom = false;

  @override
  Widget build(BuildContext context) {
    final size = MediaQuery.of(context).size;
    final percentDy = (size.height - ScrollDownBottomHeight) / size.height;
    return Scaffold(
      body: SafeArea(
        top: false,
        bottom: false,
        child: ShareDataWidget(
          isbottom: isbottom,
          child: Stack(
            children: [
              MineDressupWidget(),
              MineHomePage(
                percentDy: percentDy,
                onScrollToButtom: (isbo){
                  setState(() {
                    isbottom = isbo;
                  });
              },)
            ],
          ),
        ),
      ),
    );
  }

  @override
  bool get wantKeepAlive => true;
}


class ShareDataWidget extends InheritedWidget{

  final bool isbottom;
  final Widget child;

  ShareDataWidget({this.isbottom, this.child}) : super(child: child);

  static ShareDataWidget of(BuildContext context) {
    return context.dependOnInheritedWidgetOfExactType<ShareDataWidget>();
  }

  @override
  bool updateShouldNotify(ShareDataWidget oldWidget) {
    return oldWidget.isbottom != isbottom;
  }
}